<?php
class system extends ujn_controller {
	var $main_url = '';
	var $login_url = '';
	
	function _before() {
		$this->main_url = ujn::getCFG('plat.url.main_url');
		$this->login_url = ujn::getCFG('plat.url.login_url');
	}	

	function set_flash_version(){
		
		$errors = array();
		
		//init fversion
		$params = array( 'p' => 'facebook' );
		$url = $this->main_url . '_hookdoor/_datadoor.php?system-get_flash_version';
		$x = tls_func::rest_request('POST', $url, null, $params, false, true);
		$init_fversion = $x['data']['flag'] ? $x['data']['lists'] : '';
		
		if( !empty($_POST) ){
			$fversion  = trim((isset($_REQUEST['fversion']) && !empty($_REQUEST['fversion'])) ? $_REQUEST['fversion'] : 0);

			if( empty( $fversion ) ) $errors['fversion'] = '版本号不能为空!';
			if( $fversion == $init_fversion ) $errors['fversion'] = '没作任务改变';

			if( empty($errors) ){
				$params = array( 'p' => 'facebook', 'fversion' => $fversion);
				$url = $this->main_url . '_hookdoor/_datadoor.php?system-set_flash_version';
				$x = tls_func::rest_request('POST', $url, null, $params, false, true);
				if( $x['data']['flag'] ){
					echo "<script>window.alert('设置成功 ! ');</script>";
				}
			}
		}
		
		$this->assign(array(
			'errors' => $errors,
			'init_fversion' => isset($fversion) ? $fversion : $init_fversion,
		));
	}
	
	function get_flash_vars(){
		//get version
		$params = array( 'p' => 'facebook' );
		$url = $this->main_url . '_hookdoor/_datadoor.php?system-get_flash_version';
		$x = tls_func::rest_request('POST', $url, null, $params, false, true);
		$fversion = $x['data']['flag'] ? $x['data']['lists'] : '';
		
		//get flashvars
		$params = array( 'p' => 'facebook', 'fversion' => $fversion);
		$url = $this->main_url . '_hookdoor/_datadoor.php?system-get_flash_vars';
		$x = tls_func::rest_request('POST', $url, null, $params, false, true);
		$flashvars = $x['data']['flag'] ? $x['data']['lists'] : '';
		$this->assign(array(
			'flashvars' => $flashvars,
		));
	}
}